﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Threading;
using System.Diagnostics;

namespace IcqSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            // server
            var server = "login.icq.com";
            var port = 5190;

            // user
            Session.LocalUIN = 0000000000;
            Session.Password = "PASSWORD";

            // message sequence
            Session.LocalSequence = 
                Utilities.GenerateFlapSequence();

            try
            {
                // connect to server
                Session.client = new TcpClient();
                Session.client.Connect(server, port);
                Session.stream = Session.client.GetStream();

                // launch process thread
                var ts = new ThreadStart(Session.ProcessMessages);
                Session.ProcessMessagesThread = new Thread(ts);
                Session.ProcessMessagesThread.Start();

                // wait for thread to close
                Session.ProcessMessagesThread.Join();
            }
            catch (Exception ex)
            {
                Debugger.Break();
            }

            
        }
    }
}
